package com.hpu.service;

import android.content.Context;
import android.os.Handler;

import com.hpu.callback.ElectricCallback;
import com.hpu.callback.EmptyRoomCallback;
import com.hpu.constants.HttpConstants;
import com.hpu.constants.ShareConstants;
import com.hpu.constants.UrlConstants;
import com.hpu.interceptor.ReceivedCookieInterceptor;
import com.hpu.tools.InternetTools;
import com.hpu.tools.OkHttpTools;
import com.hpu.tools.ShareTools;

/**
 * 空教室业务类，负责访问网络获取空教室数据
 * @author Administrator
 *
 */
public class ElectricService {

	private Handler handler;

	private Context context;

	public ElectricService(Handler handler, Context context) {
		this.handler=handler;
		this.context=context;
	}
	
	public void getElectric(String build) {
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
		OkHttpTools.getByCookie(new ReceivedCookieInterceptor(context),UrlConstants.getElectricity(build),
				ShareTools.get(context, ShareConstants.STORE_LOGINCOOKIE, "").toString(),
				new ElectricCallback(handler));
	}

}
